bus = (bus_type in cls._shared_instances).__new__(subclass, bus_type, mainloop = mainloop)
bus._bus_type = bus_type
if not private:
cls._shared_instances[bus_type] = bus
return bus
def close(self):
t = self._bus_type
if self.__class__._shared_instances.get(t) is self:
del self.__class__._shared_instances[t]
super(Bus, self).close()
def get_connection(self):
'''Return self, for backwards compatibility with earlier dbus-python
versions where Bus was not a subclass of Connection.
:Deprecated: since 0.80.0
'''
return self
_connection = property(get_connection, None, None, 'self._connection == self, for backwards\n compatibility with earlier dbus-python versions\n where Bus was not a subclass of Connection.')
def get_session(private = False):
'''Static method that returns a connection to the session bus.
:Parameters:
`private` : bool
If true, do not return a shared connection.
'''
return SessionBus(private = private)
get_session = staticmethod(get_session)
def get_system(private = False):
'''Static method that returns a connection to the system bus.
:Parameters:
`private` : bool
If true, do not return a shared connection.
'''
return SystemBus(private = private)
get_system = staticmethod(get_system)
def get_starter(private = False):
'''Static method that returns a connection to the starter bus.
:Parameters:
`private` : bool
If true, do not return a shared connection.
'''
return StarterBus(private = private)
get_starter = staticmethod(get_starter)
def __repr__(self):
if self._bus_type == BUS_SESSION:
name = 'session'
elif self._bus_type == BUS_SYSTEM:
name = 'system'
elif self._bus_type == BUS_STARTER:
name = 'starter'
else:
name = 'unknown bus type'
return '<%s.%s (%s) at %#x>' % (self.__class__.__module__, self.__class__.__name__, name, id(self))